﻿@*
    数据库
*@

@using NewLife.Common;
@using NewLife.Cube.Admin;
@using XCode.DataAccessLayer;
@using NewLife;

@{
    var dbs = Model as IList<DbItem>;
}

<div class="card card-flush">
    <div class="card-body">
        <div class="table-responsive dataTables_wrapper dt-bootstrap4">
            <table class="table table-hover table-row-bordered table-row-dashed gy-4">
                <thead>
                    <tr class="fs-4 text-muted">
                        <th>名称</th>
                        <th>类型</th>
                        <th>连接字符串</th>
                        <th>版本</th>
                        <th>备份</th>
                        <th>备份并压缩</th>
                        <th>下载表结构</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in dbs)
                    {
                        var dal = DAL.Create(item.Name);
                        // 密码需要保密
                        var str = item.ConnStr;
                        if (!str.IsNullOrEmpty())
                        {
                            var ss = str.Split(";");
                            for (var i = 0; i < ss.Length; i++)
                            {
                                if (ss[i].StartsWithIgnoreCase("password=", "pass=", "pwd="))
                                {
                                    ss[i] = ss[i].Substring(null, "=") + "={保密}";
                                    str = ss.Join(";");
                                    break;
                                }
                            }
                        }
                        var str2 = dal.Db.ConnectionString;
                        if (!str2.IsNullOrEmpty())
                        {
                            var ss = str2.Split(";");
                            for (var i = 0; i < ss.Length; i++)
                            {
                                if (ss[i].StartsWithIgnoreCase("password=", "pass=", "pwd="))
                                {
                                    ss[i] = ss[i].Substring(null, "=") + "={保密}";
                                    str2 = ss.Join(";");
                                    break;
                                }
                            }
                        }

                        <tr>
                            <td>@item.Name</td>
                            <td>@item.Type</td>
                            <td style="max-width:600px;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;" title="@str2">@str</td>
                            <td>@item.Version</td>
                            <td>@Html.ActionLink("备份", "Backup", new { Name = item.Name })，共 @item.Backups.ToString("n0")个</td>
                            <td>@Html.ActionLink("备份并压缩", "BackupAndCompress", new { Name = item.Name })</td>
                            <td>@Html.ActionLink("下载", "Download", new { Name = item.Name })</td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>


